home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / ecstr3.arc / STRXMOV.C < prev    next >
C/C++ Source or Header  |  1987-03-04  |  1KB  |  38 lines

  1. /*  File   : strxmov.c
  2.     Author : Richard A. O'Keefe.
  3.     Updated: 25 may 1984
  4.     Defines: strxmov()
  5.  
  6.     strxmov(dst, src1, ..., srcn, NullS)
  7.     moves the concatenation of src1,...,srcn to dst, terminates it
  8.     with a NUL character, and returns a pointer to the terminating NUL.
  9.     It is just like strmov except that it concatenates multiple sources.
  10.     Beware: the last argument should be the null character pointer.
  11.     Take VERY great care not to omit it!  Also be careful to use NullS
  12.     and NOT to use 0, as on some machines 0 is not the same size as a
  13.     character pointer, or not the same bit pattern as NullS.
  14. */
  15.  
  16. #include "strings.h"
  17. #include <varargs.h>
  18.  
  19. /*VARARGS*/
  20. char *strxmov(va_alist)
  21.     va_dcl
  22.     {
  23.        va_list pvar;
  24.        register char *dst, *src;
  25.  
  26.        va_start(pvar);
  27.        dst = va_arg(pvar, char *);
  28.        src = va_arg(pvar, char *);
  29.        while (src != NullS) {
  30.            while (*dst++ = *src++) ;
  31.            dst--;
  32.            src = va_arg(pvar, char *);
  33.        }
  34.        *dst = NUL;     /* there might have been no sources! */
  35.        return dst;
  36.     }
  37.  
  38.